package com.yimi.policyservice.repository;

import com.yimi.policyservice.entity.base.policy.PolicyDatum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface PolicyDatumRepository extends JpaRepository<PolicyDatum,String> {
    @Modifying
    @Transactional
    @Query(value = "delete from t_policy_datum where policy_addr_id = ?1",nativeQuery = true)
    void deleteByAddrId(String id);

    List<PolicyDatum> findByPolicyAddrId(String id);

    @Transactional
    @Modifying
    @Query(value = "delete from t_policy_datum where policy_addr_id=?1  and id not in  ?2",nativeQuery = true)
    void deleteByIdNotIn(String id,List<String> ids);


    @Transactional
    @Modifying
    @Query(value = "delete from t_policy_datum where policy_addr_id=?1  and policy_type = ?2",nativeQuery = true)
    void deleteByAddrIdAndType(String id, int i);
}
